/* 
 * File:   Pipe.cpp
 * Author: maxds
 * 
 * Created on 5 août 2011, 00:00
 */

#include "Pipe.h"


int    Pipe::pipe_fds[2];
mode_t Pipe::mode;
int    Pipe::fifo_id;


int Pipe::getPipeIn(){
    printf("pipIn=%d\n",fifo_id);
    return fifo_id;
}


int Pipe::getPipeOut(){
    printf("pipOut=%d\n",fifo_id);
    return fifo_id;
}


#include <cassert>
#include <cstdio>
#include <stdlib.h>



int Pipe::initPipe(){
    printf("Initialisation du called pipe\n");
    
    mode = S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH ;
    
    if (mkfifo ("fifo", mode) == -1){
       perror ("mkfifo (fifo1)"), exit (1) ; 
    }
        
    //int ret=pipe(pipe_fds);
    //assert(ret==0);
    fifo_id = open("/tmp/fifo1",mode);
    return fifo_id;
}

int Pipe::finitPipe(){
    return unlink("/tmp/fifo1");
}




